﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharpReview
{
  //  3.定义一个图书类，存放图书的编号、书名、价格、出版社、作者信息；
  //对价格进行赋值限制，小于0价格，赋值为0
  //在图书类中定义一个方法输出图书信息；
    class Books
    {
        private string isbn;
        private string bookName;
        private int price;
        private string pubCom;
        private string author;

        public string Isbn { get => isbn; set => isbn = value; }
        public string BookName { get => bookName; set => bookName = value; }
        public int Price 
        {
            get => price;
            set
            {
                if (value <= 0)
                {
                    this.price = 0;
                }
                else 
                {
                    this.price = value;
                }
            }
        }
        public string PubCom { get => pubCom; set => pubCom = value; }
        public string Author { get => author; set => author = value; }

        public void PrintBookInfo()
        {
            Console.WriteLine($"图书编号为：{this.isbn}，书名为：{this.bookName}，价格为：{this.price}，出版社为：{this.pubCom}，作者为：{this.author}\n");
        }
    }
}
